#include <windows.h>
#include <assert.h>

int main(void) {
	// global fix mem
	{
		HGLOBAL pFixMemNew, pFixMem = GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, 0);
		assert(pFixMem);

		pFixMemNew = GlobalReAlloc(pFixMem, 1024, GMEM_MOVEABLE | GMEM_FIXED);
		assert(pFixMemNew);

		pFixMem = pFixMemNew;

		sprintf(pFixMem, "hello world");
		printf("%u\n", GlobalSize(pFixMem));
		GlobalFree(pFixMem);
	}

	// global moveable mem
	{
		PVOID pMem;
		HGLOBAL hMoveMemNew, hMoveMem = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, 0);
		assert(hMoveMem);

		hMoveMemNew = GlobalReAlloc(hMoveMem, 1024, GMEM_MOVEABLE | GMEM_ZEROINIT);
		assert(hMoveMemNew);

		pMem = GlobalLock(hMoveMem);
		assert(pMem);
		sprintf(pMem, "hello world");
		GlobalUnlock(hMoveMem);

		printf("%u\n", GlobalSize(hMoveMem));
		GlobalFree(hMoveMem);
	}
	return 0;
}
